<?
	  	  include("/inc/header.html") {}
    ?>
<div class="col-lg-4">
	<div class="panel" style="height: 500px; overflow: auto;">
		<div class="panel-body">
			<ul id="tree" class="ztree" style="width:300px"; overflow:auto;"></ul>
		</div>
	</div>
</div>

<script type="text/javascript">
	var classid;
	var classname;
	var classValue;
	$(function() {
		initTree();
	});
	function initTree() {
		$.ajax({
			type : "post",
			data : {},
			url : "cmsNavbarCategoryZtree.do",
			dataType : "json",
			beforeSend : function(XMLHttpRequest) {
			},
			success : drawTree,
		});
	}
	function drawTree(data) {
		if(data.msg == "OK"){
			var setting = {
				view : {
					dblClickExpand : false,
				},
				data : {
					simpleData : {
						enable : true,
					}
				},
				check : {
					enable : false
				},
				callback : {
					onClick : onClick
				},
			};
			var zNodes = eval(data.data);
			$.fn.zTree.init($("#tree"), setting, zNodes).expandAll(true);
			zTree = $.fn.zTree.getZTreeObj("tree");
			zTree.expandNode(zTree.getNodes()[0], true);
		}else{
			alert("请求失败")
		}

	}

	function onClick(e, treeId, treeNode) {
		classid = treeNode.id;
		classname = treeNode.name;
		classValue = treeNode.value;
	}

	function save() {
		if (classid == null) {
			parent.layer.msg('请选择...');
		} else {
			var index = parent.layer.getFrameIndex(window.name);
			window.parent.$("#categoryId").val(classValue);
			window.parent.$("#categoryNameZh").val(classname);
			parent.layer.close(index);
		}
	}
</script>